package com.jomoim.action;

import net.sf.json.JSONObject;

import org.springframework.beans.factory.annotation.Autowired;

import com.jomoim.model.TestModel;
import com.jomoim.service.TestService;

/**
 * TestAction - BaseAction을 상속받아 http://localhost/*.action url을 받을 때 동작
 * @author JosephChoi
 *
 */
public class TestAction extends BaseAction {
	
	/**
	 * TestAction Class 내에서 사용할 모든 Instance는 Autowiring해서 Spring으로부터 Singleton객체를 받을 수 있도록 함
	 */
	@Autowired
	private TestService testService;
	
	/**
	 * test.action url이 들어왔을 때 동작
	 * @return
	 * @throws Exception
	 */
	public String testAction() throws Exception{
		int user_seq = testService.testService(parameters); 
		if(user_seq != 0){
			setInputStream(user_seq);
			return SUCCESS;
		}
		else{
			return ERROR;
		}
		
	}
	
	/**
	 * testAjax.action url이 들어왔을 때 동작
	 * @return
	 * @throws Exception
	 */
	public String testAjax() throws Exception{
		TestModel testModel = testService.testAjax(parameters);
		if(testModel != null){
			setInputStream(testModel);
			return SUCCESS;
		}else{
			return ERROR;
		}
	}
}
